#include "errors.hpp"
#include <sstream>

string ErrorMessage(ErrorType e)
{
	stringstream ss;
	ss<< "***ERROR CODE #" << e << ": ";
	switch(e) {
		case ERROR_LEXER:
			ss << "Error while tokenizing";
			break;
		case ERROR_PARSER:
			ss << "Error while parsing";
			break;
		case ERROR_OPERATION:
			ss << "Invalid operation";
			break;
		case ERROR_VARIABLE:
			ss << "Invalid variable name";
			break;
		case ERROR_ARGUMENTS:
			ss << "Invalid argument type";
			break;
		case ERROR_ARGUMENTCOUNT:
			ss << "Invalid number of arguments";
			break;
		case ERROR_MISMATCHBRACKETS:
			ss << "Mismatched brackets";
			break;
		case ERROR_INLINECODE:
			ss << "Missing or improper inline code";
			break;
		case ERROR_ALIAS:
			ss << "Alias not found";
			break;
		case ERROR_FILE:
			ss << "Cannot open file";
			break;
		case ERROR_ARRAYBOUNDS:
			ss << "Index beyond array bounds";
			break;
		case ERROR_DIR:
			ss << "Unable to open directory";
			break;
		case ERROR_SOCKET:
			ss << "Unable to open socket";
			break;
		case ERROR_MEMBERS:
			ss << "Invalid typedef member";
			break;
		case ERROR_MANTISSA:
			ss << "Too many decimal points";
			break;
		case ERROR_UNKNOWN:
		default:
			ss << "Unknown error. Please contact the developers for help.";
			break;
	}
	ss << "\n";
	return ss.str();
}

void _throw_error(ErrorType e)
{
	cout << ErrorMessage(e);
}
